// 当前API接口统一管理
import requests from "./requests";

import mockRequests from './mockRequests'

//  home页 三级联动接口
//  http://gmall-h5-api.atguigu.cn/api/product/getBaseCategoryList

export const reqCategoryList = () =>
  // 发请求:axios发送请求返回结果是Promise对象
  requests({
    url: '/product/getBaseCategoryList',
    method: 'GET',
  })
;
// 获取首页轮播

export const reqGetBannerList = () => mockRequests({
  url: '/banner',
  method: 'GET',
})

// 获取首页floor
export const reqFloorLists = () => mockRequests({
  url: '/floors',
  method: 'GET',
})

// 获取搜索模块数据/api/list 带参 { "category3Id": "61", "categoryName": "手机", "keyword": "小米", "order": "1:desc", "pageNo": 1, "pageSize": 10, "props": ["1:1700-2799:价格", "2:6.65-6.74英寸:屏幕尺寸"], "trademark": "4:小米"}
// 当前这个函数需要接受外部传递的参数 至少是个空对象
export const reqGetSearchInfo = params => requests({
  url: '/list',
  method: 'POST',
  data: params,
})
// 获取商品详情/api/item/{ skuId } get 参数skuId

export const reqGoodsInfo = skuId => requests({
  url: `/item/${skuId}`,
  method: 'GET',
})
// 添加到购物车(对已有物品进行数量改动)
//  /api/cart/addToCart/{ skuId }/{ skuNum } post
export const reqAddOrUpdateShopCart = (skuId, skuNum) => requests({
  url: `/cart/addToCart/${skuId}/${skuNum}`,
  method: 'POST',
});
// 获取购物车列表 /api/cart/cartList get
export const reqCartList = () => requests({
  url: '/cart/cartList',
  method: 'GET',
});
// 删除购物车商品 /api/cart/deleteCart/{skuId}  DELETE
export const reqDeleteCartById = skuId => requests({
  url: `/cart/deleteCart/${skuId}`,
  method: 'DELETE',
});
// 切换商品选中状态 /api/cart/checkCart/{skuID}/{isChecked} GET 商品选中状态0代表取消选中1代表选中

export const reqCheckedById = (skuId, isChecked) => requests({
  url: `/cart/checkCart/${skuId}/${isChecked}`,
  method: 'GET',
});
// 注册：获取验证码 /api/user/passport/sendCode/{phone}
export const reqGetCode = phone => requests({
  url: `/user/passport/sendCode/${phone}`,
  method: 'GET',
});
// 用户注册 /api/user/passport/register POST phone/password/code
export const reqUserRegister = data => requests({
  url: '/user/passport/register',
  data,
  method: 'POST',
});
// 用户登录/api/user/passport/login post phone/password
export const reqUserLogin = data => requests({
  url: '/user/passport/login',
  method: 'POST',
  data,
});
// 获取用户信息 需要带着用户的token向服务器要用户信息
// /user/passport/auth/getUserInfo  ---》请求头 get
export const reqGetUserInfo = () => requests({
  url: '/user/passport/auth/getUserInfo',
  method: 'GET',
});
// 推出登录 /api/user/passport/logout
export const reqLogout = () => requests({
  url: '/user/passport/logout',
  method: 'GET',
});
// 结算页 地址信息 /api/user/userAddress/auth/findUserAddressList get
export const reqUserAddress = () => requests({
  url: '/user/userAddress/auth/findUserAddressList',
  method: 'GET',
});
// 获取商品清单
export const reqOrderInfo = () => requests({
  url: '/order/auth/trade',
  method: 'GET',
});
// 请求订单接口pi/order/auth/submitOrder?tradeNo={tradeNo} POST
// 参数 traderNo(拼接在路径中)consignee consigneeTel deliveryAddress paymentWay orderComment orderDetailList
export const reqSubmitOrder = (tradeNo, data) => requests({
  url: `order/auth/submitOrder?tradeNo=${tradeNo}`,
  method: 'POST',
  data,
});

// 获取订单支付信息
export const reqPayInfo = orderId => requests({
  url: `/payment/weixin/createNative/${orderId}`,
  method: 'GET',
});
// 获取订单支付状态
// /api/payment/weixin/queryPayStatus/{orderId}

export const reqPayStatus = orderId => requests({
  url: `/payment/weixin/queryPayStatus/${orderId}`,
  method: 'GET',
});
// 获取个人中心 我的订单
export const reqMyOrder=(page,limit)=>requests({
  url:`/order/auth/${page}/${limit}`,
  method:'GET'
})

